<template>
  <header>
    <div class="header-logo">
      <span class="iconfont iconnew"></span>
    </div>
    <div class="header-searchInput" @click="$router.push('/search')">
      <div>
        <span class="iconfont iconsearch"></span>
        <span>搜索新闻</span>
      </div>
    </div>
    <div class="header-user">
      <router-link
        @click.native="getToken"
        class="iconfont iconwode"
        to="/"
      ></router-link>
    </div>
  </header>
</template>

<script>
export default {
  methods: {
    getToken() {
      const token = localStorage.getItem("token");
      if (token) {
        this.$router.push("/user");
      } else {
        this.$router.push("/login");
      }
    },
  },
};
</script>

<style lang="less" scoped>
header {
  height: 50 / 360 * 100vw;
  background-color: #0094ff;

  display: flex;
  justify-content: space-around;
  align-items: center;

  .header-logo {
    .iconnew {
      color: #fff;
      font-size: 50/ 360 * 100vw;
    }
  }
  .header-searchInput {
    width: 200 / 360 * 100vw;
    height: 38 / 360 * 100vw;
    line-height: 38 / 360 * 100vw;
    text-align: center;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 20 / 360 * 100vw;
    span {
      font-size: 18 / 360 * 100vw;
      color: #fff;
    }
  }
  .header-user {
    .iconwode {
      color: rgba(0, 0, 0, 0.5);
      font-size: 30 / 360 * 100vw;
    }
  }
}
</style>